package com.chance.cc.crawler.development.bootstrap.tencent.qqCarSerial;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

public class TencentStart {
    //private static final String START_URL = "https://auto.qq.com/car_public/index.shtml";
    private static final String START_URL = "https://auto.qq.com/car_public/index.shtml?serial_id=%s";
    private static final String DOMAIN = "tenxun";
    private static final String SITE = "carinfo";

    public static void main(String[] args) {
        Long nowTime = System.currentTimeMillis();
        Integer serial_id = 184;
        String start_url = String.format(START_URL,serial_id);
        CrawlerRequestRecord startRecord = CrawlerRequestRecord.builder()
                .startPageRequest(DOMAIN,CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(DOMAIN)
                .recordKey(start_url)
                .httpUrl(start_url)
                .releaseTime(nowTime)
                .filter(CrawlerEnum.CrawlerRecordFilter.keyOrDateRange)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(DOMAIN))
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(24,null))
                .build();
        startRecord.tagsCreator().bizTags().addDomain(DOMAIN);
        startRecord.tagsCreator().bizTags().addSite(SITE);

        DevCrawlerController.builder()
                .requestRecord(startRecord)
                .triggerInfo(DOMAIN,DOMAIN,System.currentTimeMillis(),DOMAIN)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(DOMAIN))
                .consoleResultPipeline()
                //.fileResultPipeline("F:\\changxi\\web_data\\carinfo.log",false)
                .requestRecord(startRecord)
                .build("com.chance.cc.crawler.development.scripts.tenxun")
                .start();
    }
}
